package com.joey.concurrency.example.singleton;

import com.joey.concurrency.annotation.NotThreadSafe;

/**
 * 静态块
 * @Author hyy
 **/

public class SingtonExample4 {
    private SingtonExample4(){ }
    //顺序问题
    private static SingtonExample4 instance = null;
    static {
        instance = new SingtonExample4();
    }


    public static SingtonExample4 getInstance(){
        return instance;
    }

    public static void main(String[] args) {
        System.out.println(instance);
        System.out.println(instance);

        System.out.println(instance.hashCode());
        System.out.println(instance.hashCode());

    }
}
